#ifndef __RENDERTARGET_H__
#define __RENDERTARGET_H__

#include "Common.h"
#include "Texture.h"
#include "Graphics/Color.h"

namespace RayFrame
{
  class Color;
  class DLL_DECLARE RenderTarget: public IObject
  {
  protected:
    size_t m_width, m_height;
    Texture* m_texture;
    Color m_clearColor;
  public:
    RenderTarget()
    { 
      m_width = m_height = -1;
      m_isOK = false;
    };

    virtual ~RenderTarget(){};

    virtual void Create(Texture* tex)
    {
      assert(tex);
      
      m_width = tex->GetWidth();
      m_height = tex->GetHeight();
      m_texture = tex;
      
      internalCreate();
    };

    virtual void Begin() = 0;
    virtual void End() = 0;

    void SetClearColor(Color c){ m_clearColor = c; }

    /// Download bitmap from video card, and save it to a Image object
    virtual void Download(Image* img) = 0;

    /// Download bitmap from video card and save it to disk directly
    virtual void Download(STRING filename, ImageFileFormat iff = IFF_BMP) = 0;

    Texture* GetTexture(){ return m_texture; };
  };

  DECL_BUCKET_TYPE(RenderTargetBucket, RenderTarget);
}

#endif /* __RENDERTARGET_H__ */
